<script setup>
import { reactive, onMounted } from "vue";
import { getShouC, getUpdataChusheng } from "@/http/api.js";
import { useRouter } from "vue-router";
const router = useRouter();
const data = reactive({
  name: "",
  xinxi: {},
});
onMounted(() => {
  xinxi();
});

// 信息数据
const xinxi = async () => {
  const id = localStorage.getItem("id");
  const res = await getShouC(id);
  console.log(res);
  data.xinxi = res;
  data.name = res.major;
};
// 更新数据
const inof = async () => {
  let obj = {
    id: localStorage.getItem("id"),
    major: data.name,
  };
  const res = await getUpdataChusheng(obj);
  console.log(res);
};
const baocu = () => {
  inof();
  xinxi();
  router.back();
};
</script>
<template>
  <div class="sex">
    <header>
      <van-icon name="arrow-left" @click="$router.back()" />
      <h3>修改个人信息</h3>
      <p @click="baocu">保存</p>
    </header>
    <div class="InputBox">
      <input type="text" v-model="data.name" />
    </div>
  </div>
</template>
<style lang="scss" scoped>
.sex {
  height: 100vh;
  overflow: hidden;
  background-color: #f8f8f8;
  header {
    display: flex;
    height: 88px;
    line-height: 88px;
    text-align: center;
    font-size: 32px;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    background: #fff;
  }
  .InputBox {
    margin-top: 50px;
    input {
      width: 100%;
      padding: 40px 40px;
      border: none;
      border-bottom: 1px solid rgba(0, 0, 0, 0.247);
      background-color: #f8f8f8;
      font-size: 32px;
    }
  }
}
</style>
